import { request, post, get } from "@/utils/request";
import ApiResult from "@/api/base/ApiResult";
import {
  manageQuery,
  manageAdd,
  manageUpdate,
  manageStatus,
  manageUp, IInsTreeItem
} from "@/api/modules/orgManage";

/**
 * 获取机构树
 * @returns {promise} Promise
 */
export async function queryTree(data: manageQuery) {
  const rs: ApiResult<any> = await request(`merchant/merchantIns/queryTree`,data);
  return rs;
}

export async function queryTree2(): Promise<ApiResult<IInsTreeItem[]>> {
  return request('merchant/merchantIns/queryTree2')
}

/**
 * 新增机构
 * @returns {promise} Promise
 */
export async function addNew(data: manageAdd) {
  const rs: ApiResult<any> = await request("merchant/merchantIns/addNew", data);
  return rs;
}
/**
 * 更新机构
 * @returns {promise} Promise
 */
export async function update(data: manageUpdate) {
  const rs: ApiResult<any> = await request("merchant/merchantIns/update", data);
  return rs;
}
/**
 * 更新机构状态
 * @returns {promise} Promise
 */
export async function upStatus(data: manageStatus) {
  const rs: ApiResult<any> = await request("merchant/merchantIns/upStatus", data);
  return rs;
}
/**
 * 新增机构
 * @returns {promise} Promise
 */
export async function serviceByParent(data: manageUp) {
  const rs: ApiResult<any> = await request("merchant/merchantIns/serviceByParent", data);
  return rs;
}
/**
 * 查询全部机构
 * @returns {promise} Promise
 */
export async function allOrg() {
  const rs: ApiResult<any> = await request("merchant/merchantIns/simpleList");
  return rs;
}
